package ds.tree;

public class IdenticalTrees {
	
	private static class TreeNode{
		int value;
		TreeNode left = null;
		TreeNode right = null;
		
		TreeNode(int val){
			this.value = val;
		}
		
		public String toString(){
			return String.valueOf(value);
		}
	}
	
	public static boolean compare(TreeNode one, TreeNode two){
		if(one == null && two == null) {
			return true;
		}		
		if(one != null && two != null ){
			System.out.println(one.value + " == " + two.value);
			if(one.value == two.value && compare(one.left, two.left) && compare(one.right,two.right)){
				return true;
			}
		}
		return false;
	}
	
	private static TreeNode treeOne(){
		TreeNode A = new TreeNode(1);
		TreeNode B = new TreeNode(2);
		TreeNode C = new TreeNode(3);
		TreeNode D = new TreeNode(4);
		TreeNode E = new TreeNode(5);
		
		A.left = B;
		A.right = C;
		B.left = D;
		B.right = E;
		
		return A;
	}	

	private static TreeNode treeTwo(){
		TreeNode A = new TreeNode(1);
		TreeNode B = new TreeNode(2);
		TreeNode C = new TreeNode(3);
		TreeNode D = new TreeNode(4);
		TreeNode E = new TreeNode(5);
		TreeNode F = new TreeNode(6);
		A.left = B;
		A.right = C;
		B.left = D;
		B.right = E;
//		E.left = F;
		
		return A;
	}	

	public static void main(String[] args) {
		System.out.println(compare(treeOne(),treeTwo()));

	}

}
